import {
  Form,
  Input,
  Select,
  InputNumber,
  Button,
  Radio,
  Checkbox,
  Modal,
  Table,
  Popconfirm,
} from 'antd';
import { connect } from 'net';

const FormItem = Form.Item;
const { TextArea } = Input;
const RadioGroup = Radio.Group;
const Option = Select.Option;

@Form.create()
export default class SignInfoForm extends React.Component {
  state = {};

  okHandle = () => {
    const { form, handleAdd } = this.props;
    form.validateFields((err, fieldsValue) => {
      if (err) return;
      handleAdd(fieldsValue);
      form.resetFields();
    });
  };

  getTitle = () => {
    const {
      curData,
      } = this.props;
    if (curData) {
          return '修改报名信息';
      } else {
          return '添加报名信息';
      }
  };

  close = () => {
    const { form, handleModalVisible } = this.props;
    form.resetFields();
    handleModalVisible();
  };

  render() {
    const { modalVisible, projectCode, form, curData, zubieCode } = this.props;

    return (
      <Modal
        title={this.getTitle()}
        width={1000}
        visible={modalVisible}
        onOk={this.okHandle}
        onCancel={() => this.close()}
        okText="保存"
        cancelText="关闭"
        maskClosable={false}
      >
        <div>
          {form.getFieldDecorator('id', {
              rules: [{ required: false},],
              initialValue: curData && curData.id,
            })(<Input type="hidden" placeholder="请输入"/>)}
          {form.getFieldDecorator('zubieCode', {
              rules: [{ required: false},],
              initialValue: zubieCode,
            })(<Input type="hidden" placeholder="请输入"/>)}
          <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="所属团队">
            {form.getFieldDecorator('team', {
              rules: [{ required: true},],
              initialValue: curData && curData.team,
            })(<Input />)}
          </FormItem>
          <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="种子号">
            {form.getFieldDecorator('seedNo', {
              initialValue: curData && curData.seedNo,
            })(<InputNumber style={{ width: '100%' }} min={1} max={16} />)}
          </FormItem>
          <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="队内技术号">
            {form.getFieldDecorator('teamNo', {
              initialValue: curData && curData.teamNo,
            })(<InputNumber style={{ width: '100%' }} min={1} max={16} />)}
          </FormItem>
          {form.getFieldDecorator('userId1', {
              rules: [{ required: false},],
              initialValue: curData && curData.athleteList[0].id,
            })(<Input type="hidden" placeholder="请输入"/>)}
          <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="姓名1">
            {form.getFieldDecorator('userName1', {
              rules: [{ required: true}],
              initialValue: curData && curData.athleteList[0].userName
            })(<Input placeholder="请输入姓名"/>)}
          </FormItem>
          <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="身份证1">
            {form.getFieldDecorator('idCard1', {
              rules: [{ required: false}],
              initialValue: curData && curData.athleteList[0].idCard
            })(<Input placeholder="请输入身份证"/>)}
          </FormItem>
          {projectCode && ("WD" === projectCode||"MD"=== projectCode||"HD"=== projectCode) &&
          <div>
            {form.getFieldDecorator('userId2', {
              rules: [{ required: false},],
              initialValue: curData && curData.athleteList[1].id,
            })(<Input type="hidden" placeholder="请输入"/>)}
          <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="姓名2">
            {form.getFieldDecorator('userName2', {
              rules: [{ required: true}],
              initialValue: curData && curData.athleteList[1].userName
            })(<Input placeholder="请输入姓名"/>)}
          </FormItem>
          <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="身份证2">
            {form.getFieldDecorator('idCard2', {
              rules: [{ required: false}],
              initialValue: curData && curData.athleteList[1].idCard
            })(<Input placeholder="请输入身份证"/>)}
          </FormItem></div>
          }
        </div>
      </Modal>
    );
  }
}
